﻿@using ST = EmoneyWeiXinCommon.StringTools;
@{
    ViewBag.Title = "粉丝消息添加";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<link href="@ST.GetStaticFile("Models/css/colorbox.css")" rel="stylesheet" />
<script src="@ST.GetStaticFile("Scripts/jquery.colorbox.js")"></script>

<div class="right">
    <h3>消息回复管理</h3>
    <!--manage-->
    <div class="manage">
        <!--manage_top-->
        <div class="manage_top">
            <div class="manage_register">
                <p><span>关注着昵称：</span>@ViewBag.Nickname</p>
            </div>
            <div class="manage_register">
                <p><span>关注者OpenId：</span><input type="text" value="@ViewBag.openid" /></p>
                <p>
                    <input type="button" value="查看历史记录" />
                </p>
            </div>
            <div class="manage_register">
                <div class="manage_register_p03">
                    <p>
                        <i class="icon iconfont">&#xe602;</i>
                        <i class="icon iconfont" id="divtwxx">&#xe609;</i>
                        <i class="icon iconfont">&#xe60a;</i>
                        <i class="icon iconfont">&#xe608;</i>
                        <i class="icon iconfont">&#xe603;</i>
                    </p>
                    <textarea class="manage_register_mass" id="txtdhwb"></textarea>
                </div>
            </div>
            <p class="manage_add">
                <a style="cursor:pointer;" id="btnTijiao">推送</a>
            </p>
        </div>
        <!--manage_top end-->
        <p class="manage_line"></p>
        <!--manage_bottom-->
        <div class="manage_bottom">
            <div class="manage_batch_box">
                <div class="manage_batch">
                    <ul>
                        <div id="divContentStockD">
                        </div>
                    </ul>
                </div>
                <!--manage_batch end-->
                <!--manage_page-->
                <div class="manage_page" id="manage_page">
                </div>
                <!--manage_page end-->
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var pageIndex = 1;
    var pageSize = 10;
    var newsid = "";
    $(window).ready(function () {
        getContent();

        $('#divtwxx').colorbox({ href: "@ST.GetTrendsFile("Report/NewsReportListSelected")?weixinid=@ViewBag.weixinid", title: false, iframe: true, width: "95%", height: "95%" });

        $("#btnTijiao").click(function () {
            var txtdhwb = $("#txtdhwb").val();
            if (txtdhwb != "") {
                $.ajax({
                    type: "post",
                    url: '@ST.GetTrendsFile("StockDoctorlog/ajaxTuisong?action=dhwb")' + "&random=" + Math.random(),
                    async: true,
                    data: { weixinid: "@ViewBag.weixinid", openid: "@ViewBag.openid", sid: "@ViewBag.sid", txtdhwb: txtdhwb },
                    dataType: "html",
                    success: function (result) {
                        if (result == "45015") {
                            alert("该用户已经超过48小时没有发生上行");
                        }
                        else if (result == 1) {
                            pageIndex = 1;
                            getContent();
                            $("#txtdhwb").html("");
                        }
                        else if (result == "40001") {
                            alert("请联系管理员");
                        } else {
                            pageIndex = 1;
                            getContent();
                            $("#txtdhwb").html("");
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert("error");
                    }
                });
            }
        })



    })

    function UpdatePD(newsreportids, titles, menunames, updatetimes) {
        $('#divtwxx').colorbox.close();
        newsid = newsreportids;
        if (newsid != "" && newsid != "^") {
            $.ajax({
                type: "post",
                url: '@ST.GetTrendsFile("StockDoctorlog/ajaxTuisong?action=newsreport")' + "&random=" + Math.random(),
                async: true,
                data: { weixinid: "@ViewBag.weixinid", openid: "@ViewBag.openid", sid: "@ViewBag.sid", newsreportid: newsid },
                dataType: "html",
                success: function (result) {
                    if (result == "45015")
                    {
                        alert("该用户已经超过48小时没有发生上行");
                    }
                    else if (result == 1)
                    {
                        pageIndex = 1;
                        getContent();
                    }
                    else if (result == "40001")
                    {
                        alert("请联系管理员");
                    }
                    else
                    {
                        pageIndex = 1;
                        getContent();
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert("error");
                }
            });
        }
    }

    function getContent() {
        $.ajax({
            type: "get",
            url: "@ST.GetTrendsFile("StockDoctorlog/Index_addData")" + "?random=" + Math.random(),
            async: true,
            data: {
                pageindex: pageIndex,
                weixinid: "@ViewBag.weixinid",
                openid: "@ViewBag.openid"
            },
            dataType: "html",
            success: function (result) {
                $("#divContentStockD").html(result);
                PageCountHtml();
            }
        });
    }


    function PageCountHtml() {
        var groupid = "";
        $.ajax({
            type: "get",
            url: "@ST.GetTrendsFile("StockDoctorlog/Index_dataaddNum")",
            async: true,
            data: {
                weixinid: "@ViewBag.weixinid",
                openid: "@ViewBag.openid"
            },
            dataType: "html",
            success: function (result) {
                pageCount = Math.ceil(result / pageSize);
                if (pageCount == 0) {
                    pageCount = 1;
                }
                $("#manage_page").html(PageHtml(pageIndex, pageCount));
                $("#manage_page .manage_page_right").click(function () {
                    pageIndex = parseInt($("#txtPageNum").val()) + parseInt($(this).attr("tname"));
                    $("#manage_page").html(PageHtml(pageIndex, pageCount));
                    getContent();
                });
                $("#manage_page .tiaozhuan").click(function () {
                    var pageNum = $("#txtPageNum").val();
                    try {
                        pageIndex = parseInt(pageNum);
                    } catch (e) {
                        alert("请输入数字");
                        return false;
                    }
                    if (pageNum > 0 && pageNum <= pageCount) {
                        $("#manage_page").html(PageHtml(pageIndex, pageCount));
                        getContent();
                    }
                    else {
                        alert("当前数字超出范围");
                        return false;
                    }
                })
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert("error");
            }
        });
    }
</script>
